package com.kamistoat.netty.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/**
 * 使用 channel.transfer执行快速拷贝
 */
public class NIOFileChannel04 {
    public static void main(String[] args) throws Exception{
        FileInputStream fileInputStream =
                new FileInputStream("/home/kamistoat/ubuntu/Netty_Learning/.Netty.markdown_images/200e53d9.png");
        FileOutputStream fileOutputStream =
                new FileOutputStream("/home/kamistoat/ubuntu/Netty_Learning/src/main/java/com/kamistoat/netty/nio/pic.jpg");
        FileChannel inChannel = fileInputStream.getChannel();
        FileChannel outChannel = fileOutputStream.getChannel();

        // 直接进行channel转换
        outChannel.transferFrom(inChannel, 0, inChannel.size());

        fileInputStream.close();
        fileOutputStream.close();;
    }
}
